export const namespace = "courseGroup";
import { Flex, Image, Space, Tag, Typography } from "antd";
import default_avater from "@/assets/imgs/default_avater.png";
import default_avater_female from "@/assets/imgs/default_avater_female.png";
import { vipTypeList } from "@/utils/common";
import { render } from "@/app";
import dayjs from "dayjs";
const { Text } = Typography;
export const calcColumns = (params) => {
  const { operate } = params;
  const columns = [
    {
      title: "会员信息",
      dataIndex: "id",
      hideInSearch: true,
      width: 200,
      render: (text, record) => {
        return (
          <Flex justify={"flex-start"} align={"center"}>
            <div>
              <Image
                width={40}
                src={
                  record.avatar
                    ? record.avatar
                    : record.sex == "0"
                    ? default_avater
                    : default_avater_female
                }
              />
            </div>
            <div style={{ marginLeft: "10px" }}>
              <div>{record.wechatUserName}</div>
              <div style={{ color: "#999999" }}>{record.wechatUserPhone}</div>
            </div>
          </Flex>
        );
      },
    },
    {
      title: "支付方式",
      dataIndex: "payType",
      width: 150,
      render: (text, record) => {
        return record.payType == 1 ? (
          "微信支付"
        ) : (
          <div>会员卡({vipTypeList[record.vipType].text})</div>
        );
      },
    },
    {
      title: "卡名称",
      dataIndex: "vipcardName",
      width: 200,
      render: (text, record) => {
        return record.payType == 0 ? (
          <Space direction="vertical" size="small">
            <Text>{record.vipcardName}</Text>
            <Text type="secondary" copyable ellipsis>{record.cardNo}</Text>
          </Space>
        ) : (
          "-"
        );
      },
    },
    {
      title: "支付金额",
      dataIndex: "payValue",
      width: 100,
      hideInSearch: true,
      render: (text, record) => {
        return record.payType == 0 ? (
          <div>
            {record.vipType == 2
              ? "-"
              : (record && record.payValue) || record.payValue == 0
              ? record.vipType == 1
                ? Number(record.payValue) / 100 +
                  vipTypeList[record.vipType].status
                : Number(record.payValue) + vipTypeList[record.vipType].status
              : "-"}
          </div>
        ) : (
          Number(record.payValue) / 100 + "元"
        );
      },
    },
    {
      title: "状态",
      dataIndex: "status",
      width: 100,
      valueEnum: {
        "1": { text: "排队中", status: "Default" },
        "2": { text: "已预约", status: "Processing" },
        "3": { text: "已完成", status: "Success" },
        "4": { text: "已取消", status: "Default" },
      },
    },
    {
      title: "签到状态",
      dataIndex: "signinFlag",
      width: 100,
      valueEnum: {
        "1": { text: "已签到", status: "Success" },
        "0": { text: "未签到", status: "Default" },
      },
    },
  ];

  columns.push(operate);
  return columns;
};
export const calcColumnsTwo = (params) => {
  const { operate } = params;
  const columns = [
    {
      title: "学员信息",
      dataIndex: "nickName_tel",
      hideInSearch:true,
      render: (_, record) => {
        return (
          <Space direction="vertical" size="small">
            <Text>{record.nickName}</Text>
            <Text type="secondary">{record.tel}</Text>
          </Space>
        );
      },
    },
    {
      title: "卡信息",
      dataIndex: "vipcardName_cardNo",
      hideInSearch:true,
      render: (_, record) => {
        return (
          <Space direction="vertical" size="small">
            <Space>
              <Text>{record.vipcardName}</Text>
              <Tag color="blue">{vipTypeList[record.vipType].shortName}</Tag>
            </Space>
            <Text type="secondary">{record.cardNo}</Text>
          </Space>
        );
      },
    },
    {
      title: "姓名",
      dataIndex: "nickName",
      hidden: true,
      width: 150,
    },
    {
      title: "手机号码",
      hidden: true,
      dataIndex: "tel",
    },
    {
      title: "卡名称",
      dataIndex: "vipcardName",
      width: 200,
      hidden:true,
    },
    {
      title: "卡号",
      dataIndex: "cardNo",
      hidden:true,
    },
    {
      title: "有效期至",
      dataIndex: "effectiveTime",
      hideInSearch:true,
      render: (_, record) => {
        return <Text>
          {record.effectiveTime ? dayjs(record.effectiveTime).format("YYYY-MM-DD") : "-"}
        </Text>
      },
    },
    {
      title: "卡余额",
      dataIndex: "currentCardLimit",
      hideInSearch: true,
      render: (_, record) => {
        return (
          <span>
            {record.vipType != 2
              ? record.vipType == 1
                ? Number(record.currentCardLimit) / 100 +
                  vipTypeList[record.vipType].status
                : record.currentCardLimit + vipTypeList[record.vipType].status
              : "-"}
          </span>
        );
      },
    },
  ];

  columns.push(operate);
  return columns;
};
